---* 戴笠 弹跳
---* 优先弹没有弹过的英雄  都弹过则消失
---* 以当前目标范围内寻找下一个弹射目标或者目标已死亡 没有则技能终止
---@class SkillEffect224100:BaseSkillEffect
SkillEffect224100 = ClientFight.CreateClass("SkillEffect224100",ClientFight.BaseSkillEffect)
local t = SkillEffect224100

---触发自己能 这里重新找目标 如果没有就此结束
---@param parentSkill FightUsingSkill
---@param target Fighter
---@param triggerSkill FightUsingSkill
---@return SkillEffectResult
function t:triggerSkill(parentSkill,target,triggerSkill)
    local parentSkillBean = parentSkill.skill.skillBean
    local skillBean = triggerSkill.skill.skillBean
    local fight = parentSkill.fight
    local fighter = parentSkill.fighter
    if (parentSkillBean.f_SkillID == triggerSkill.skill.skillBean.f_SkillID) then
        return SkillEffectResult.New(false,false);
    end
    -- 如果目标血量大于自己时
    local parentTarget = parentSkill.target
    if (parentTarget.hp >= fighter.hp ) then
        SkillRoleMgr.savePathFile(string.format("[%s]%s戴笠准备触发火焰符子技能%s因为父技能目标血量高于自己而停止触发",
         fight.frame,fighter.fighterId,triggerSkill.skill.skillBean.f_SkillID
        ));
        return  SkillEffectResult.New(true,false);
    end
    -- 找这个技能系列从来没有打过的目标
    local targets = SkillManager.selectAttackTargets(fight, fighter, triggerSkill.skill,
            skillBean.f_TargetRange, skillBean.f_Target, AttackUtils.getAttackRadius(fighter, triggerSkill.skill),
            AttackUtils.getAttackShape(fighter, triggerSkill.skill), parentSkill.target.position, skillBean.f_TagActivate,
            SkillManager.getRootSkill(triggerSkill).attackedTargets);
    if (#targets == 0) then
        target = targets[fight:random(targets)]
    else
        return SkillEffectResult.New(true,false);
    end

    local skillStartFighter;
    if(parentSkill.target.fighterId == fighter.fighterId) then
        skillStartFighter = fighter;
    else
        skillStartFighter = parentSkill.target
    end
    triggerSkill.target = target
    triggerSkill.startPosition = parentSkill.position
    triggerSkill.targetPosition = target.position

    parentSkill.excludes[target.fighterId] = true
    SkillManager.getRootSkill(parentSkill).attackedTargets[parentSkill.target.fighterId] = true
    parentSkill.attackedTargets[parentSkill.target.fighterId] = true
    local frameInfo = ReportManager.flyToJsonString(fight, skillStartFighter, target, triggerSkill)
    table.insert(fight.actions, frameInfo);
    FightManager.playActions(frameInfo,triggerSkill)
    SkillManager.addSkill(fight, triggerSkill);

    -- 开始释放技能
    SkillManager.prepareSkill(triggerSkill, parentSkill.position);

    -- 子技能加速
    if (parentSkill.frame < parentSkill.skipFrame) then
        triggerSkill.skipFrame = parentSkill.skipFrame - parentSkill.frame
    end

    local logf = target;
    SkillRoleMgr.savePathFile(string.format("[%s]%s戴笠准备触发火焰符子技能%s,目标%s,技能起始坐标%s,目标坐标%s",
    fight.frame,fighter.fighterId,triggerSkill.skill.skillBean.f_SkillID,logf.fighterId,
    triggerSkill.startPosition, triggerSkill.targetPosition
    ));

    return SkillEffectResult.New(true,true);
end

t.New()